Microphones are used in various electronic devices, such as smartphones, portable computers, tablets, hearing aids, etc. In some situations, it is desirable to provide pressure sensors to electronic devices for sensing the atmospheric pressure in the vicinity. For example, the pressure sensor can be used as an altimeter to aid altitude measurement by the GPS on a smartphone. In another application, the pressure sensor can be used as a barometer to detect change in the air pressure in order to obtain climate information. However, when placed within the device (e.g., a smartphone), the pressure sensor might lose accuracy due to the design of the device, which substantially isolates components inside the device from ambient conditions. In addition, the pressure sensor is sensitive to case deformation and internal heat sources (e.g., application processors) of the device, which further worsens the accuracy of the pressure sensor.